<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：基础设置顶部
-->

<template>
	<div>
		<div style="padding-top:10px;">
			<Form ref="params" :model="params" :rules="ruleValidate" :label-width="300" label-position="right">		
				<div style="width:100%;height: 60px;line-height: 60px;float:left;display:table;">
					<div style="width: 80%;text-align: left;float: left;" align="left">
						<FormItem label="现金(请填写联系方式)" prop="fs1">
							<Input v-model="params.fs1" placeholder="如果是现金支付,请填写联系方式!" clearable style="width: 90%;font-size:14px;"></Input>
							<Checkbox v-model="fs1check">是否启用</Checkbox>
						</FormItem>
					</div>
				</div>
	
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 80%;text-align: left;float: left;" align="left">
						<FormItem label="银行转账(请填写收款人银行账户)" prop="fs2">
							<Input v-model="params.fs2" placeholder="如果是银行转账,请填写收款人银行账户!" clearable style="width: 90%;font-size:14px;"></Input>
							<Checkbox v-model="fs2check">是否启用</Checkbox>
						</FormItem>
					</div>
					
				</div>
				
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 80%;text-align: left;float: left;" align="left">
						<FormItem label="互联网缴费(如为1%,则填写1)" prop="fs3">
							<Input v-model="params.fs3" placeholder="如果是互联网缴费,请输入需要用户需要多缴纳的费率" clearable style="width: 90%;font-size:14px;"></Input>
							<Checkbox  v-model="fs3check" >是否启用</Checkbox>
						</FormItem>
					</div>
				</div>
			</Form>	
		</div>
		<div style="width:100%;height: 60px;line-height: 60px;float:left;margin-bottom: 20px;">
			<Button type="info" style="float:left;margin-left:10%;" v-on:click="save()">保存</Button>
		</div>	
	</div>
</template>
<script>
	export default {
		name:"home",
		data() {
			//长度控制
			const lenPass = (rule, str, callback) => {
			  if(str.length>rule.length){
			  	 callback(new Error('字符串长度在1-'+rule.length+'之间！'));
			  }
			  return callback();
			};
				//正数控制
			const zsPass = (rule, value, callback) => {
			    let reg = /^\+?[1-9]|[1-9][0-9]*$/; 
				if(!reg.test(value)){
				    callback(new Error('请输入正数！'));
				}else{
				  	return callback();
				}
			};
			
			return {
				fs1check:true, 
				fs2check:true,
				fs3check:true,
				params:{
					fs1:'',
					fs2:'',
					fs3:'',
					fs1state:'1',
					fs2state:'1',
					fs3state:'1',
				},
				ruleValidate: {
					fs1: [
						{length:100,validator:lenPass,trigger:'blur'}
					],
					fs2: [
						{length:100,validator:lenPass,trigger:'blur'},
					],
					fs3: [
						{length:100,validator:lenPass,trigger:'blur'},
						{validator:zsPass,trigger:'blur'}
					]
				},
				
			}
		},
		components: {
			
		},
		computed: {
			
		},
		methods: {
			getJffs(){
				this.$http.get("/host/stgl/jffs/getJffs.html")
				.then(result => {
					
					this.params.fs1=result.FS1;
					this.params.fs2=result.FS2;
					this.params.fs3=result.FS3;
					this.params.fs1state=result.FS1STATE;
					this.params.fs2state=result.FS2STATE;
					this.params.fs3state=result.FS3STATE;
					
					if(this.params.fs1state=="0"){
						this.fs1check=true;
					}else{
						this.fs1check=false;
					}
					if(this.params.fs2state=="0"){
						this.fs2check=true; 
					}else{
						this.fs2check=false;
					}
					if(this.params.fs3state=="0"){
						this.fs3check=true;
					}else{
						this.fs3check=false;
					}
				});
			},
			save(){
				this.params.fs1state=1;
				this.params.fs2state=1;
				this.params.fs3state=1;
					
				if(this.fs1check){
					this.params.fs1state=0;
				}
				if(this.fs2check){
					this.params.fs2state=0;
				}
				if(this.fs3check){
					this.params.fs3state=0;
				}
			
				const params={
					fs1:this.params.fs1,
					fs2:this.params.fs2,
					fs3:this.params.fs3,
					fs1state:this.params.fs1state,
					fs2state:this.params.fs2state,
					fs3state:this.params.fs3state,
				}
				this.$http.post("/host/stgl/jffs/updateJffs.html",params)
				.then(datas => {
					if(datas){
						this.$Modal.success({
                            title: "提示",
                            content: "保存成功"
                        });	
					}else{
						this.$Modal.error({
                            title: "提示",
                            content:"保存失败"
                        });	
					}
				});
				
			}
		},
		mounted(){	
			//获取缴费方式信息
			this.getJffs();
		},
		watch:{
			
		},
	}
</script>

<style>
</style>



